package com.sleep.ws.client.config;

import com.sleep.ws.client.core.WsClient;
import com.sleep.ws.client.property.WsClientProperties;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @author Sleep-6000
 * @date 2024/3/8
 */
@AutoConfiguration
@EnableConfigurationProperties(WsClientProperties.class)
public class WsClientAutoConfiguration {

    @Bean
    public WsClient nettyWebSocketClient(WsClientProperties wsClientProperties) {
        String ip = wsClientProperties.getIp();
        String port = wsClientProperties.getPort();
        String path = wsClientProperties.getPath();
        return new WsClient("ws://" + ip + ":" + port + "/" + path);
    }

}
